package opencl.utils;

import static org.bridj.Pointer.pointerToFloats;

import org.bridj.Pointer;

import com.nativelibs4java.opencl.CLBuffer;
import com.nativelibs4java.opencl.CLContext;
import com.nativelibs4java.opencl.JavaCL;
import com.nativelibs4java.opencl.CLMem.Usage;

public class KernelParameterConverter {

    private CLContext context = JavaCL.createBestContext();
    private static Object parameter;

    private <T> KernelParameterConverter(T param) {
        parameter = param;
    }

    public static <T> KernelParameterConverter convert(T param) {
        return new KernelParameterConverter(param);
    }

    CLBuffer<Float> toFloatBuffer() {
        Pointer<Float> floatPointer = pointerToFloats((Float) parameter);
        return context.createFloatBuffer(Usage.Input, floatPointer);
    }

}